package com.wx.controller;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.wx.model.Sta;
import com.wx.serviceImpl.StaServiceImpl;

/**
 * Servlet implementation class ModifyStaServlet
 */
@WebServlet("/servlet/ModifyStaServlet")
public class ModifyStaServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public ModifyStaServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String staid = request.getParameter("staid");
		String statypeid = request.getParameter("statypeid");
		String staname = request.getParameter("staname");
		String brand = request.getParameter("brand");
		String statype = request.getParameter("statype");
		String stacount = request.getParameter("stacount");
		String price = request.getParameter("price");
		String dis = request.getParameter("dis");
		String salenum = request.getParameter("salenum");
		Sta sta = new Sta();
		sta.setStaid(Integer.parseInt(staid));
		sta.setStatypeid(Integer.parseInt(statypeid));
		sta.setStaname(staname);
		sta.setBrand(brand);
		sta.setStatype(statype);
		sta.setStacount(Integer.parseInt(stacount));
		sta.setPrice(Double.parseDouble(price));
		sta.setStatype(statype);
		sta.setDis(dis);
		sta.setSalenum(Integer.parseInt(salenum));
		try {
			new StaServiceImpl().updateSta(sta);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		response.sendRedirect("../manage/index.jsp");
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
